package com.jccfc.message;

import com.jccfc.MessgeFactory;
import com.jccfc.iMessage.impl.EmailMessage;
import com.jccfc.iMessage.impl.MobileMessage;
import com.jccfc.iMessage.impl.ServerControlMessage;
import com.jccfc.iMessageFactory.impl.EmailMessageFactory;
import com.jccfc.iMessageFactory.impl.MobileMessageFactory;
import com.jccfc.iMessageFactory.impl.ServerControlMessageFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: qym
 * @Date: 2021/1/8 11:40
 * @Description: 用于微服务 将短信工厂实例放入用户项目ioc容器中
 */
@Configuration
public class SendMessageConfiguration {

    /**
     * @Auther: qym
     * @Description: 手机短信发送实例注入ioc容器
     * @Param:
     * @Return:
     * @Date: 2021/1/8 11:43
     */
    @Bean
    public MobileMessage getMobileMessage() {
        //获取手机消息发送实例
        MobileMessage mobileMessage = (MobileMessage) MessgeFactory.getMessage(MobileMessageFactory.class);
        return mobileMessage;
    }

    /**
     * @Auther: qym
     * @Description: 邮件发送实例注入ioc容器
     * @Param:
     * @Return:
     * @Date: 2021/1/12 15:13
     */
    @Bean
    public EmailMessage getEmailMessage() {
        //获取邮件消息发送实例
        EmailMessage emailMessage = (EmailMessage) MessgeFactory.getMessage(EmailMessageFactory.class);
        return emailMessage;
    }

    /**
     * @Auther: qym
     * @Description: 监控服务消息发送实例
     * @Param:
     * @Return:
     * @Date: 2021/1/19 11:42
     */
    @Bean
    public ServerControlMessage getServerControlMessage() {
        //获取监控服务消息发送实例
        ServerControlMessage serverControlMessage = (ServerControlMessage) MessgeFactory.getMessage(ServerControlMessageFactory.class);
        return serverControlMessage;
    }

}
